package com.weipai.springboot.module.controller;

import com.weipai.springboot.model.InventoryIn;
import com.weipai.springboot.model.InventoryOut;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.service.StorageDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author songmengqiang
 * @create 2018-08-24 11:21
 **/
@RestController
public class StorageDetailController {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private StorageDetailService storageDetailService;

    /**
     * 新增出库明细
     *
     * @param
     * @return
     */
    @PostMapping("/storageDetail/outStorage")
//    public Response outStorage(InventoryOut inventoryOut) {
    public Response outStorage(String storageId,String shopId,String skuNumber,Integer inNums,String remark) {
//        return storageDetailService.outStorage(inventoryOut);
        return storageDetailService.outStorage(storageId,shopId,skuNumber,inNums,remark);
    }

    /**
     * 入库
     * @param inventoryIn
     * @return
     */
    @PostMapping("/storageDetail/inStorage")
    public Response inStorage(InventoryIn inventoryIn){
        return storageDetailService.inStorage(inventoryIn);
    }

    /**
     * 入库明细列表
     *
     * @param categoryId
     * @param page
     * @param size
     * @param draw
     * @return
     */
    @GetMapping("/storageDetail/listInDetail")
    public Response listInDetail(@RequestParam(value = "categoryId", required = false) String categoryId, 
                                 @RequestParam(value = "page") Integer page, 
                                 @RequestParam(value = "size") Integer size, 
                                 @RequestParam(value = "draw") String draw,
                                 @RequestParam(value = "search", required = false) String search) {
        return storageDetailService.listInDetail(categoryId, page, size, draw, search);
    }

    /**
     * 出库明细列表
     *
     * @param categoryId
     * @param page
     * @param size
     * @param draw
     * @return
     */
    @GetMapping("/storageDetail/listOutDetail")
    public Response listOutDetail(@RequestParam(value = "categoryId", required = false) String categoryId, 
                                  @RequestParam(value = "page") Integer page, 
                                  @RequestParam(value = "size") Integer size, 
                                  @RequestParam(value = "draw") String draw,
                                  @RequestParam(value = "search", required = false) String search) {
        return storageDetailService.listOutDetail(categoryId, page, size, draw, search);
    }
}
